home *** CD-ROM | disk | FTP | other *** search
/ This Disc Bytes! / Power Computing - The Disc 2 - This Disc Bytes.ISO / mac / CodeWarrior 7 Lite for 68K / MacOS Support / Headers / Universal Headers / ConditionalMacros.h < prev    next >
Text File  |  1995-07-06  |  9KB  |  263 lines

  1. /*
  2.      File:        ConditionalMacros.h
  3.  
  4.      Contains:    Compile time feature switches to achieve platform independent sources.
  5.  
  6.      Version:    Technology:    Universal Interface Files 2.1
  7.                  Package:    Universal Interfaces 2.1 in “MPW Latest” on ETO #18
  8.  
  9.      Copyright:    © 1984-1995 by Apple Computer, Inc.
  10.                  All rights reserved.
  11.  
  12.      Bugs?:        If you find a problem with this file, use the Apple Bug Reporter
  13.                  stack.  Include the file and version information (from above)
  14.                  in the problem description and send to:
  15.                      Internet:    apple.bugs@applelink.apple.com
  16.                      AppleLink:    APPLE.BUGS
  17.  
  18. */
  19.  
  20. #ifndef __CONDITIONALMACROS__
  21. #define __CONDITIONALMACROS__
  22.  
  23. /*
  24.     This file sets up the following compiler independent conditionals:
  25.     
  26.     GENERATINGPOWERPC        - Compiler is generating PowerPC instructions
  27.     GENERATING68K            - Compiler is generating 68k family instructions
  28.     GENERATING68881            - Compiler is generating mc68881 floating point instructions
  29.     GENERATINGCFM            - Code being generated assumes CFM calling conventions
  30.     CFMSYSTEMCALLS            - No A-traps.  Systems calls are made using CFM and UPP's
  31.     
  32.     SystemSevenFiveOrLater    - Compiled code will only be run on a System 7.5 or later Macintosh
  33.     SystemSevenOrLater        - Compiled code will only be run on a System 7.0 or later Macintosh
  34.     SystemSixOrLater        - Compiled code will only be run on a System 6.0 or later Macintosh
  35.                               A developer should set the appropriate flag on the compiler command-
  36.                               line or in a file processed before this file.  This will allow the
  37.                               certain optimizations to be made which can result in smaller, faster
  38.                               applications.
  39.     
  40.     CGLUESUPPORTED            - Interface library will support "C glue" functions (function names
  41.                               are: all lowercase, use C strings instead of pascal strings, use 
  42.                               Point* instead of Point).
  43.  
  44.     OLDROUTINENAMES            - "Old" names for Macintosh system calls are allowed in source code.
  45.                               (e.g. DisposPtr instead of DisposePtr). The names of system routine
  46.                               are now more sensitive to change because CFM binds by name.  In the 
  47.                               past, system routine names were compiled out to just an A-Trap.  
  48.                               Macros have been added that each map an old name to its new name.  
  49.                               This allows old routine names to be used in existing source files,
  50.                               but the macros only work if OLDROUTINENAMES is true.  This support
  51.                               will be removed in the near future.  Thus, all source code should 
  52.                               be changed to use the new names! You can set OLDROUTINENAMES to false
  53.                               to see if your code has any old names left in it.
  54.     
  55.     OLDROUTINELOCATIONS     - "Old" location of Macintosh system calls are used.  For example, c2pstr 
  56.                               has been moved from Strings to TextUtils.  It is conditionalized in
  57.                               Strings with OLDROUTINELOCATIONS and in TextUtils with !OLDROUTINELOCATIONS.
  58.                               This allows developers to upgrade to newer interface files without suddenly
  59.                               all their code not compiling becuase of "incorrect" includes.  But, it
  60.                               allows the slow migration of system calls to more understandable file
  61.                               locations.  OLDROUTINELOCATIONS currently defaults to true, but eventually
  62.                               will default to false.
  63.     
  64.     PRAGMA_ALIGN_SUPPORTED    - Compiler supports "#pragma align=..." directives. The only compilers that
  65.                               can get by without supporting the pragma are old classic 68K compilers
  66.                               that will only be used to compile older structs that have 68K alignment
  67.                               anyways.  
  68.     
  69.     PRAGMA_IMPORT_SUPPORTED    - Compiler supports "#pragma import on/off" directives.  These directives
  70.                               were introduced with the SC compiler which supports CFM 68K.  The directive
  71.                               is used to tell the compiler which functions will be called through a 
  72.                               transition vector (instead of a simple PC-relative offset).  This allows 
  73.                               the compiler to generate better code.  Since System Software functions are
  74.                               implemented as shared libraries and called through transition vectors,
  75.                               all System Software functions are declared with "#pragma import on".
  76.                               
  77.     
  78.     There are some invariants among the conditionals:
  79.     
  80.     GENERATINGPOWERPC != GENERATING68K
  81.     GENERATING68881 => GENERATING68K
  82.     GENERATINGPOWERPC => GENERATINGCFM
  83.     GENERATINGPOWERPC => CFMSYSTEMCALLS
  84.     CFMSYSTEMCALLS => GENERATINGCFM
  85.     GENERATINGPOWERPC => SystemSevenOrLater
  86.     SystemSevenFiveOrLater => SystemSevenOrLater
  87.     SystemSevenOrLater => SystemSixOrLater
  88.     PRAGMA_IMPORT_SUPPORTED => CFMSYSTEMCALLS
  89.     
  90. */
  91. /*
  92.  
  93.     Set up UNIVERSAL_INTERFACES_VERSION
  94.     
  95.         0x210 => version 2.1
  96.         This conditional did not exist prior to version 2.1
  97. */
  98. #define UNIVERSAL_INTERFACES_VERSION 0x0210
  99. /*
  100.  
  101.     Set up GENERATINGPOWERPC and GENERATING68K
  102.  
  103. */
  104. #ifdef GENERATINGPOWERPC
  105.     #ifndef GENERATING68K
  106. #define GENERATING68K !GENERATINGPOWERPC
  107.     #endif
  108. #endif
  109. #ifdef GENERATING68K
  110.     #ifndef GENERATINGPOWERPC
  111. #define GENERATINGPOWERPC !GENERATING68K
  112.     #endif
  113. #endif
  114. #ifndef GENERATINGPOWERPC
  115.     #if defined(powerc) || defined(__powerc)
  116. #define GENERATINGPOWERPC 1
  117.     #else
  118. #define GENERATINGPOWERPC 0
  119.     #endif
  120. #endif
  121. #ifndef GENERATING68K
  122.     #if GENERATINGPOWERPC
  123. #define GENERATING68K 0
  124.     #else
  125. #define GENERATING68K 1
  126.     #endif
  127. #endif
  128. /*
  129.  
  130.     Set up GENERATING68881 
  131.  
  132. */
  133. #if GENERATING68K
  134.     #if defined(applec) || defined(__SC__)
  135.         #ifdef mc68881
  136. #define GENERATING68881 1
  137.         #endif
  138.     #else
  139.         #ifdef __MWERKS__
  140.             #if __MC68881__
  141. #define GENERATING68881 1
  142.             #endif
  143.         #endif
  144.     #endif
  145. #endif
  146. #ifndef GENERATING68881
  147. #define GENERATING68881 0
  148. #endif
  149. /*
  150.  
  151.     Set up GENERATINGCFM and  CFMSYSTEMCALLS
  152.  
  153. */
  154. #if GENERATINGPOWERPC || defined(__CFM68K__)
  155. #define GENERATINGCFM 1
  156. #define CFMSYSTEMCALLS 1
  157. #else
  158. #define GENERATINGCFM 0
  159. #define CFMSYSTEMCALLS 0
  160. #endif
  161. /*
  162.  
  163.     Set up SystemSevenFiveOrLater, SystemSevenOrLater, and SystemSixOrLater
  164.  
  165. */
  166. #ifndef SystemSevenFiveOrLater
  167. #define SystemSevenFiveOrLater 0
  168. #endif
  169. #ifndef SystemSevenOrLater
  170.     #if GENERATINGCFM
  171. #define SystemSevenOrLater 1
  172.     #else
  173. #define SystemSevenOrLater SystemSevenFiveOrLater
  174.     #endif
  175. #endif
  176. #ifndef SystemSixOrLater
  177. #define SystemSixOrLater SystemSevenOrLater
  178. #endif
  179. /*
  180.  
  181.     Set up OLDROUTINENAMES and OLDROUTINELOCATIONS
  182.  
  183. */
  184. #ifndef OLDROUTINENAMES
  185. #define OLDROUTINENAMES 1
  186. #endif
  187. #ifndef OLDROUTINELOCATIONS
  188. #define OLDROUTINELOCATIONS 1
  189. #endif
  190. /*
  191.  
  192.     Define C specific conditionals
  193.  
  194. */
  195. #ifndef CGLUESUPPORTED
  196.     #ifdef THINK_C
  197. #define CGLUESUPPORTED 0
  198.     #else
  199. #define CGLUESUPPORTED 1
  200.     #endif
  201. #endif
  202. #ifndef PRAGMA_ALIGN_SUPPORTED
  203.     #if GENERATINGPOWERPC || defined(__MWERKS__) || ( defined(__SC__) && (__SC__ >= 0x0800) )
  204.         #define  PRAGMA_ALIGN_SUPPORTED 1
  205.     #else
  206.         #define  PRAGMA_ALIGN_SUPPORTED 0
  207.     #endif
  208. #endif
  209. #ifndef PRAGMA_IMPORT_SUPPORTED
  210.     #if __CFM68K__
  211. #define PRAGMA_IMPORT_SUPPORTED 1
  212.     #else
  213. #define PRAGMA_IMPORT_SUPPORTED 0
  214.     #endif
  215. #endif
  216. /*
  217.  
  218.     Set up old "USES..." conditionals to support 1.0 universal interface files
  219.  
  220.     The USESxxx names are old, but cannot be removed yet because source code that
  221.     uses them might still compile, but do the wrong thing. 
  222. */
  223. #ifndef USES68KINLINES
  224. #define USES68KINLINES GENERATING68K
  225. #endif
  226. #define USESCODEFRAGMENTS GENERATINGCFM
  227. #define USESROUTINEDESCRIPTORS GENERATINGCFM
  228. /*
  229.     The following macros isolate the use of inlines from the routine prototypes.
  230.     A routine prototype will always be followed by on of these inline macros with
  231.     a list of the opcodes to be inlined.  On the 68K side, the appropriate inline
  232.     code will be generated.  On platforms that use code fragments, the macros are
  233.     essentially NOPs.
  234. */
  235. #if CFMSYSTEMCALLS
  236. #define ONEWORDINLINE(trapNum)
  237. #define TWOWORDINLINE(w1,w2)
  238. #define THREEWORDINLINE(w1,w2,w3)
  239. #define FOURWORDINLINE(w1,w2,w3,w4)
  240. #define FIVEWORDINLINE(w1,w2,w3,w4,w5)
  241. #define SIXWORDINLINE(w1,w2,w3,w4,w5,w6)
  242. #define SEVENWORDINLINE(w1,w2,w3,w4,w5,w6,w7)
  243. #define EIGHTWORDINLINE(w1,w2,w3,w4,w5,w6,w7,w8)
  244. #define NINEWORDINLINE(w1,w2,w3,w4,w5,w6,w7,w8,w9)
  245. #define TENWORDINLINE(w1,w2,w3,w4,w5,w6,w7,w8,w9,w10)
  246. #define ELEVENWORDINLINE(w1,w2,w3,w4,w5,w6,w7,w8,w9,w10,w11)
  247. #define TWELVEWORDINLINE(w1,w2,w3,w4,w5,w6,w7,w8,w9,w10,w11,w12)
  248. #else
  249. #define ONEWORDINLINE(trapNum) = trapNum
  250. #define TWOWORDINLINE(w1,w2) = {w1,w2}
  251. #define THREEWORDINLINE(w1,w2,w3) = {w1,w2,w3}
  252. #define FOURWORDINLINE(w1,w2,w3,w4)  = {w1,w2,w3,w4}
  253. #define FIVEWORDINLINE(w1,w2,w3,w4,w5) = {w1,w2,w3,w4,w5}
  254. #define SIXWORDINLINE(w1,w2,w3,w4,w5,w6)     = {w1,w2,w3,w4,w5,w6}
  255. #define SEVENWORDINLINE(w1,w2,w3,w4,w5,w6,w7)      = {w1,w2,w3,w4,w5,w6,w7}
  256. #define EIGHTWORDINLINE(w1,w2,w3,w4,w5,w6,w7,w8)      = {w1,w2,w3,w4,w5,w6,w7,w8}
  257. #define NINEWORDINLINE(w1,w2,w3,w4,w5,w6,w7,w8,w9)      = {w1,w2,w3,w4,w5,w6,w7,w8,w9}
  258. #define TENWORDINLINE(w1,w2,w3,w4,w5,w6,w7,w8,w9,w10)  = {w1,w2,w3,w4,w5,w6,w7,w8,w9,w10}
  259. #define ELEVENWORDINLINE(w1,w2,w3,w4,w5,w6,w7,w8,w9,w10,w11)      = {w1,w2,w3,w4,w5,w6,w7,w8,w9,w10,w11}
  260. #define TWELVEWORDINLINE(w1,w2,w3,w4,w5,w6,w7,w8,w9,w10,w11,w12)      = {w1,w2,w3,w4,w5,w6,w7,w8,w9,w10,w11,w12}
  261. #endif
  262. #endif /* __CONDITIONALMACROS__ */
  263.